<?php
/*
 * @分销商城
 * @功能说明：商品分类管理
 * @更新说明：暂无更新
 * @文件名 CateController.class.php
 * @编码 UTF-8
 * @创建时间 2016-3-7 下午3:42:04
 * @创建人 XING
 */

namespace wap\Controller;
class CateController extends ApibaseController
{
    /*
	 * 分销商城_商品分类管理
	 * @date: 2016-3-7 下午3:42:18
	 * @editor: XING
	 */
	public function main(){
		forLegal($this->realSek);
		$getCateEntity = M('CateEntity')
				       ->where('parent_id = 0')->select();
		if($getCateEntity){
			foreach($getCateEntity AS $val){
				$data = array();
				$getSonsData = M('CateEntity')
							 ->where(array('parent_id'=>$val['cate_id']))->select();
				if($getSonsData){
					foreach($getSonsData AS $vv){
						$data[] = array(
									'cate_id' => $vv['cate_id'],
									'cate_name' => $vv['cate_name'],
									'parent_id' => $vv['parent_id']
								);
					}
				}
				$output[] = array(
							'cate_id' => $val['cate_id'],
							'cate_name' => $val['cate_name'],
							'cate_pic' => $val['logo_url'],
							'sons' => $data
						);
			}
			
			$this->assign('data',$output);
			
			$this->display('cate/main');
		}else{
			dataFormat('',0,'参数缺失');
		}
	}
	
	public function detorys(){
		session_destroy();
		\Think\Cache::getInstance()->clear();
		exit('done!');
	}
	
}